< previous page page_658 next page >

Page 658
z0678-01.gif
Figure 18.9
Folding up a hypercube.
You can convert this rotation into a simpler one by first translating the cube so that the plane of rotation coincides with the X-Z plane. You would first translate by distance 1 in the Y direction, rotate around the X-Z plane, and then translate by distance 1 in the Y direction.
Example program Fold uses the subroutine FoldYW to animate the process of rotating an object around a plane parallel to the X-Z plane. This routine takes as parameters the value of the Y and W coordinates of the plane. It translates the object so that the plane of rotation coincides with the X-Z plane, rotates the object, and then translates the object back.
e10a6a0a59f035e870d90cca05b85fce.gif
' Animate folding this cube across the Y = y,
' W = w plane. 
Private Sub FoldYW(ByVal col As Collection, _
    ByVal y As Single, ByVal W As Single, _
    ByVal theta As Single)
Dim cube As Polyline4d
Dim i As Single
Dim next_time As Long
Dim T1(1 To 5, 1 To 5) As Single
Dim r(1 To 5, 1 To 5) As Single
Dim T2(1 To 5, 1 To 5) As Single
Dim T1R(1 To 5, 1 To 5) As Single
Dim All(1 To 5, 1 To 5) As Single

    next_time = GetTickCount + MS_PER_FRAME

    ' Create the transformation matrices.
    m4Translate T1, 0, -y, 0, -W

 
< previous page page_658 next page >